import path from 'path'
import koffi from 'koffi'
class HChandler {
  constructor() {
    this.hikvisionSDK = null
    this.hasInitialized = false
    this.initCfg = null
    this.initSDK = null
    this.msgCallback = () => {}
  }
  // 加载dll文件
  loadDll() {
    try {
      let hcDirPath = path.resolve('resources', 'HCplugins')
      let hcDllPath = path.resolve(hcDirPath, 'HCNetSDK.dll')
      this.hikvisionSDK = koffi.load(hcDllPath)
      //   初始化配置
      this.initCfg = this.hikvisionSDK.func('NET_DVR_SetSDKInitCfg', 'int', ['int', 'char *'])
      //   初始化sdk
      this.initSDK = this.hikvisionSDK.func('NET_DVR_Init', 'int', [])

      this.hasInitialized = true
      return 1
    } catch (error) {
      this.hasInitialized = false
      return 0
    }
  }
  generalSetting() {
    this.msgCallback
  }
}
const singleIns = new HChandler()
export default singleIns
